//
//  HomeAddGoodsNextTableViewCell.m
//  ZJControlsClass
//
//  Created by mac on 2024/12/3.
//

#import "HomeAddGoodsNextTableViewCell.h"

@interface HomeAddGoodsNextTableViewCell ()

@property (nonatomic,strong) UIView * follewView;
@property (nonatomic,strong) UILabel * toolLabel;
@property (nonatomic,strong) UITextField * toolTextF;
@property (nonatomic,strong) UILabel * sizeLabel;
@property (nonatomic,strong) UITextField * sizeTextF;
@property (nonatomic,strong) UILabel * numLabel;
@property (nonatomic,strong) UITextField * numTextF;

@end

@implementation HomeAddGoodsNextTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self){
        
        self.contentView.backgroundColor = [UIColor whiteColor];
        [self configUI];

        
    }
    return self;
}

-(void)setModel:(propssModel *)model{
    _model = model;
    NSString *title = model.title;
    if (!title || [title isEqualToString:@""]) {
        title = model.name;
    }
    self.toolLabel.text = [NSString stringWithFormat:@"%@名称",title];
    self.toolTextF.placeholder = [NSString stringWithFormat:@"%@名称",title];
//    self.toolTextF.text = model.name;
    self.sizeTextF.text = model.spec;
    self.numTextF.text = @"0";
}



-(void)configUI{
    
    [self.contentView addSubview:self.follewView];
    [self.follewView addSubview:self.toolLabel];
    [self.contentView addSubview:self.toolTextF];
    [self.follewView addSubview:self.sizeLabel];
    [self.contentView addSubview:self.sizeTextF];
    [self.follewView addSubview:self.numLabel];
    [self.contentView addSubview:self.numTextF];
    
    [self.follewView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.top.right.equalTo(self.contentView);
        make.height.equalTo(@(ALIGN_HEIGHT_PT(30)));
    }];
    
    [self.toolLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.contentView).with.offset(ALIGN_WIDTH_PT(7.5));
        make.top.equalTo(self.contentView);
        make.width.equalTo(@((SCREEN_WIDTH - ALIGN_WIDTH_PT(68)) / 3));
        make.height.equalTo(@(30));
    }];
    
    [self.toolTextF mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.contentView).with.offset(ALIGN_WIDTH_PT(7.5));
        make.top.equalTo(self.toolLabel.mas_bottom).with.offset(ALIGN_HEIGHT_PT(5));
        make.width.equalTo(@((SCREEN_WIDTH - ALIGN_WIDTH_PT(68)) / 3));
        make.height.equalTo(@(ALIGN_HEIGHT_PT(40)));
    }];

    
    [self.sizeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.toolTextF.mas_right).with.offset(ALIGN_WIDTH_PT(15));
        make.centerY.equalTo(self.toolLabel.mas_centerY);
        make.width.equalTo(@((SCREEN_WIDTH - ALIGN_WIDTH_PT(68)) / 3));
        make.height.equalTo(@(30));
    }];
    
    [self.sizeTextF mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.toolTextF.mas_right).with.offset(ALIGN_WIDTH_PT(15));
        make.centerY.equalTo(self.toolTextF.mas_centerY);
        make.width.equalTo(@((SCREEN_WIDTH - ALIGN_WIDTH_PT(68)) / 3));
        make.height.equalTo(@(ALIGN_HEIGHT_PT(40)));
    }];

    
    
    [self.numLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.sizeTextF.mas_right).with.offset(ALIGN_WIDTH_PT(15));
        make.centerY.equalTo(self.toolLabel.mas_centerY);
        make.width.equalTo(@((SCREEN_WIDTH - ALIGN_WIDTH_PT(68)) / 3));
        make.height.equalTo(@(30));
    }];
    
    [self.numTextF mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.sizeTextF.mas_right).with.offset(ALIGN_WIDTH_PT(15));
        make.centerY.equalTo(self.toolTextF.mas_centerY);
        make.width.equalTo(@((SCREEN_WIDTH - ALIGN_WIDTH_PT(68)) / 3));
        make.height.equalTo(@(ALIGN_HEIGHT_PT(40)));
    }];

}

#pragma mark -- 懒加载

-(UIView *)follewView{
    if (!_follewView){
        _follewView = [UIView new];
        _follewView.backgroundColor = COLOR_RGB(243, 244, 250);
    }
    return _follewView;
}


-(UILabel *)toolLabel{
    if (!_toolLabel) {
        _toolLabel = [UILabel new];
        _toolLabel.font = FONT14;
        _toolLabel.textColor = [UIColor blackColor];
        _toolLabel.text = @"货物名称";
        _toolLabel.textAlignment = NSTextAlignmentCenter;
    }
    return _toolLabel;
}

-(UITextField *)toolTextF{
    if (!_toolTextF){
        _toolTextF = [UITextField new];
        _toolTextF.font = FONT14;
        _toolTextF.textAlignment = NSTextAlignmentCenter;
        _toolTextF.textColor = [UIColor blackColor];
        _toolTextF.placeholder = @"货物名称";
        _toolTextF.layer.cornerRadius = 5;
        _toolTextF.layer.masksToBounds = YES;
        _toolTextF.layer.borderColor = COLOR_RGB(212, 216, 224).CGColor;
        _toolTextF.layer.borderWidth = 1;
    }
    return _toolTextF;
}


-(UILabel *)sizeLabel{
    if (!_sizeLabel) {
        _sizeLabel = [UILabel new];
        _sizeLabel.font = FONT14;
        _sizeLabel.textColor = [UIColor blackColor];
        _sizeLabel.text = @"规格";
        _sizeLabel.textAlignment = NSTextAlignmentCenter;
    }
    return _sizeLabel;
}

-(UITextField *)sizeTextF{
    if (!_sizeTextF){
        _sizeTextF = [UITextField new];
        _sizeTextF.font = FONT14;
        _sizeTextF.textAlignment = NSTextAlignmentCenter;
        _sizeTextF.textColor = [UIColor blackColor];
        _sizeTextF.placeholder = @"规格";
        _sizeTextF.layer.cornerRadius = 5;
        _sizeTextF.layer.masksToBounds = YES;
        _sizeTextF.layer.borderColor = COLOR_RGB(212, 216, 224).CGColor;
        _sizeTextF.layer.borderWidth = 1;
    }
    return _sizeTextF;
}

-(UILabel *)numLabel{
    if (!_numLabel) {
        _numLabel = [UILabel new];
        _numLabel.font = FONT14;
        _numLabel.textColor = [UIColor blackColor];
        _numLabel.textAlignment = NSTextAlignmentCenter;
        _numLabel.text = @"数量";
    }
    return _numLabel;
}

-(UITextField *)numTextF{
    if (!_numTextF){
        _numTextF = [UITextField new];
        _numTextF.font = FONT14;
        _numTextF.textAlignment = NSTextAlignmentCenter;
        _numTextF.textColor = [UIColor blackColor];
        _numTextF.keyboardType = UIKeyboardTypeNumberPad;
        _numTextF.text = @"0";
        _numTextF.layer.cornerRadius = 5;
        _numTextF.layer.masksToBounds = YES;
        _numTextF.layer.borderColor = COLOR_RGB(212, 216, 224).CGColor;
        _numTextF.layer.borderWidth = 1;
    }
    return _numTextF;
}


@end
